package com.hunktimes.wholesale.vm

import androidx.lifecycle.MutableLiveData
import com.hunktimes.wholesale.base.BaseViewModel
import com.hunktimes.wholesale.extension.launch
import com.hunktimes.wholesale.net.WholeSaleRepository
import com.hunktimes.wholesale.net.model.ApiResponse
import com.hunktimes.wholesale.net.model.GetCaptcha
import com.hunktimes.wholesale.util.L

/**
 * Author: Delete
 * Date: 2020/8/7 17:29
 * Description:
 *
 */
class RegistVM : BaseViewModel() {
    val phone = MutableLiveData<String>("")
    val smsCode = MutableLiveData<String>("")

    val smsCodeResult = MutableLiveData<ApiResponse<Any?>>()

    fun sendSmsCode() {
        launch({
            val phone = phone.value!!
            val smsResult = WholeSaleRepository.getSmsCode(GetCaptcha(phone))
            smsCodeResult.value = smsResult
        }, { e ->
            L.d("RegistVM sendSmsCode error -> ${e.message}")
        })
    }

}